package com.gscitysfy.cus.drain.modules.inspection.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gscitysfy.cus.drain.modules.common.entity.DrainInspectionMnFile;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * @author Administrator
 * @since 2022-10-14 15:00:46
 */
@Getter
@Setter
@TableName("drain_inspection_mn_problem")
public class DrainInspectionMnProblem implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键id
     */
    @TableId
    @Schema(name = "cmKid", description = "主键id")
    private Long cmKid;

    /**
     * 关联任务id
     */
    @Schema(name = "cmJobId", description = "关联任务id")
    private Long cmJobId;

    /**
     * 问题依据
     */
    @Schema(name = "cmProblemBasis", description = "问题依据")
    private String cmProblemBasis;

    /**
     * 问题类别
     */
    @Schema(name = "cmProblemType", description = "问题类别")
    private String cmProblemType;

    /**
     * 问题描述
     */
    @Schema(name = "cmProblemDetail", description = "问题描述")
    private String cmProblemDetail;

    /**
     * 位置描述
     */
    @Schema(name = "cmProblemLocationDetail", description = "位置描述")
    private String cmProblemLocationDetail;

    /**
     * 位置维度
     */
    @Schema(name = "cmProblemLocationLat", description = "位置维度")
    private String cmProblemLocationLat;

    /**
     * 位置经度
     */
    @Schema(name = "cmProblemLocationLng", description = "位置经度")
    private String cmProblemLocationLng;

    /**
     * 问题上报时间
     */
    @Schema(name = "cmProblemReportTime", description = "问题上报时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date cmProblemReportTime;

    /**
     * 问题关联的附件，多个用逗号分隔
     */
    @Schema(name = "cmProblemAttachment", description = "问题关联的附件，多个用逗号分隔")
    private String cmProblemAttachment;

    /**
     * 上报人id
     */
    @Schema(name = "cmProblemReportUserId", description = "上报人id")
    private Long cmProblemReportUserId;

    /**
     * 上报人姓名
     */
    @Schema(name = "cmProblemReportUserName", description = "上报人姓名")
    private String cmProblemReportUserName;

    /**
     * 上报人电话
     */
    @Schema(name = "cmProblemReportUserPhone", description = "上报人电话")
    private String cmProblemReportUserPhone;

    /**
     * 问题状态
     */
    @Schema(name = "cmProblemStatus", description = "问题状态")
    private String cmProblemStatus;


    /**
     * 问题审核状态，0表待审核，1表示审核通过，2表示审核不通过
     */
    @Schema(name = "cmProblemApprovalStatus", description = "问题审核状态，0表待审核，1表示审核通过，2表示审核不通过")
    private Integer cmProblemApprovalStatus;


    public void setCmProblemApprovalStatus(Integer cmProblemApprovalStatus) {
        this.cmProblemApprovalStatus = cmProblemApprovalStatus;
        if(Objects.nonNull(cmProblemApprovalStatus)){
            if(0 == cmProblemApprovalStatus){
                this.cmProblemApprovalStatusDesc = "待复核";
            }
            if(1 == cmProblemApprovalStatus){
                this.cmProblemApprovalStatusDesc = "复核通过";
            }
            if(2 == cmProblemApprovalStatus){
                this.cmProblemApprovalStatusDesc = "复核不通过";
            }
        }
    }

    /**
     * 审核状态描述
     */
    @TableField(exist = false)
    private String cmProblemApprovalStatusDesc;

    /**
     * 复核意见
     */
    @Schema(name = "cmProblemApprovalComments", description = "复核意见")
    private String cmProblemApprovalComments;


    /**
     * 0(直接上报问题)，1(巡检中上报问题)
     */
    @Schema(name = "problemType", description = "0(直接上报问题)，1(巡检中上报问题)")
    private Integer problemType;


    /**
     * 是否创建维修单 0表示未创建，1表示创建
     */
    @Schema(name = "cmProblemIsCreateOrder", description = "是否创建维修单 0表示未创建，1表示创建")
    private Integer cmProblemIsCreateOrder;

    /**
     * 是否创建维修单描述
     */
    @TableField(exist = false)
    private String cmProblemIsCreateOrderDesc;

    public void setCmProblemIsCreateOrder(Integer cmProblemIsCreateOrder) {
        this.cmProblemIsCreateOrder = cmProblemIsCreateOrder;
        if(Objects.nonNull(cmProblemIsCreateOrder)) {
            if (0 == cmProblemIsCreateOrder) {
                this.cmProblemIsCreateOrderDesc = "未创建";
            }
            if (1 == cmProblemIsCreateOrder) {
                this.cmProblemIsCreateOrderDesc = "创建";
            }
        }
    }


    /**
     * 问题编号
     */
    @Schema(name = "cmProblemNo", description = "问题编号")
    private String cmProblemNo;

    @TableField(fill = FieldFill.INSERT)
    private String cmCreator;

    @TableField(fill = FieldFill.UPDATE)
    private String cmModifier;

    private String cmOrgflag;

    private Long cmRegflag;

    private String cmTenantid;

    @TableField(fill = FieldFill.INSERT)
    private Date cmAddtime;

    @TableField(fill = FieldFill.UPDATE)
    private Date cmUptime;

    private Long cmVersion;

    @TableField(fill = FieldFill.INSERT)
    private Boolean cmUsable;

    @TableField(exist = false)
    private List<DrainInspectionMnFile> fileList;

}
